const database = require('./database.json')
const Dictionary = {

	_map() {
		return database
	},

	getVLList(em) {
		const list = this._map()[em]
		const res = list.map(item => {
			return {
				value: item.enumValue,
				label: item.name
			}
		})
		return res
	},

	getName(em, value) {
		let res = value
		const list = this._map()[em]
		list.forEach(item => {
			if (item.enumValue == value) {
				res = item.name
				return
			}
		})
		return res
	},
	install(Vue, options) {
		Vue.prototype.$dn = this.getName.bind(this) // 获取字典名称
		Vue.prototype.$dv = this.getVLList.bind(this) // 获取指定枚举字典集合
	}
}

export default Dictionary
